package com.yunhe.sms.view.student;

import com.yunhe.sms.control.StudentController;
import com.yunhe.sms.mode.Student;

import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.BiConsumer;

public class StudentList {
    public static int studentListUI(List<Student> studentList) {
        System.out.println("********************学员信息管理系统-学员管理********************");
        System.out.println("学号\t\t姓名\t\t年龄\t\t性别\t电话");
        if (null!= studentList){
            studentList.forEach(student -> System.out.println(student.getId()+"\t\t"+student.getName()+"\t\t"+student.getAge()+ "\t\t"+student.getSex()+"\t"+student.getPhone()));
        }
        System.out.println("1.添加学员\t\t2.修改学员\t3.删除学员\t4.返回主页\t\t5.刷新");
        System.out.print("请输入操作码:");
        Scanner sc = new Scanner(System.in);
        try{
            int i = sc.nextInt();
            if(i < 1 || i >5){
                throw new Exception("操作码未识别！");
            }
            return i;
        }catch (Exception e){
            String msg = e.getMessage();   //得到 异常提示信息
            System.out.println(null != msg ? msg : "输入不合法!");
            return studentListUI(studentList);
        }
    }
}
